package com.testscripts;

    import net.sourceforge.htmlunit.corejs.javascript.ObjToIntMap.Iterator;

import org.apache.jasper.tagplugins.jstl.core.Set;
import org.apache.xpath.operations.String;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
      
    public class PopupWindowTest {  
      
      
        /** 
         * Quinty's Test 
         *  
         */  
        public static void main(String[] args) {    
            WebDriver dr = new FirefoxDriver();  
            String url ="file:///C:/Documents and Settings/Administrator/桌面/main.html";;  
            dr.get(url);      
            dr.findElement(By.id("51")).click();  
          
            String currentWindow = dr.getWindowHandle();  
            
            Set<String> handles = dr.getWindowHandles();  
            Iterator<String> it = handles.iterator();  
            while(it.hasNext()){  
                if(currentWindow == it.next()){  
                	continue;
                }  
                WebDriver   window = dr.switchTo().window(it.next());  
                System.out.println("title,url = "+window.getTitle()+","+window.getCurrentUrl());  
            }  
        }  
      
    }  